import { Injectable } from '@nestjs/common'
import { CreateRecordDto } from './dto/create-record.dto'
import { UpdateRecordDto } from './dto/update-record.dto'
import { PrismaService } from 'src/prisma/prisma.service'

@Injectable()
export class RecordService {
  constructor(private prisma: PrismaService) {}
  create(createRecordDto: CreateRecordDto) {
    return this.prisma.record.create({ data: createRecordDto })
  }

  findAll() {
    return this.prisma.record.findMany({
      include: { team: true },
    })
  }

  findOne(id: number) {
    return this.prisma.record.findFirst({ where: { id } })
  }

  update(id: number, updateRecordDto: UpdateRecordDto) {
    return this.prisma.record.update({ where: { id }, data: updateRecordDto })
  }

  remove(id: number) {
    return this.prisma.record.delete({ where: { id } })
  }
}
